﻿@using Topro.Entity.Enum;
<div class="easyui-layout" data-options="fit: true">
    <div data-options="region: 'center', border: false" style="overflow: hidden;">
        <div class="easyui-layout" data-options="fit: true">
            <div data-options="region:'north',border: false,split:true">
                <div class="data-tools clearfix">
                    <div class="pull-left form-inline ">
                    </div>
                    <div class="pull-right">
                        <form class="form-inline" id="formSearch">
                            <div class="input-group input-group-sm">
                                <label class="input-group-addon m5_l">单据号：</label>
                                <input class="form-control" name="name" type="text" autocomplete="off">
                            </div>

                            <button type="button" class="btn btn-default btn-sm active" id="btnSearch"><span class="glyphicon glyphicon-search"></span> 搜索</button>
                        </form>
                    </div>
                </div>
            </div>
            <div data-options="region:'center',split: false, border: false">
                <!-- 表格数据 -->
                <table id="commonInventoryDG"></table>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">

    var commonInventoryDG = $('#commonInventoryDG');

    $(function () {
        //搜索
        $(".search").click(function(){
            //表单
            var searchform = $("#searchForm").serializeArray();
            //表单转为Json
            var queryParams = commonStockOutDG.getJson(searchform);

            commonDatagrid.datagrid({
                queryParams: queryParams
            });

            return false;
        });
        //固定行
        Topro.UI.DataGrid(commonInventoryDG, {
            fit: true,
            method: "post",
            url: "@Url.Action("InventoryQuery", "Module")",
            queryParams: null,
            idField: 'id',
            pagination: true,
            singleSelect: true,
            rownumbers: true,
            showFooter: true,
            autoEditing:false,
            frozenColumns: [
                [
                    { field: 'ck', checkbox: true },
                    {
                        field: 'orderId',
                        title: '单据号',
                        width: 150,
                        align: 'left',
                    }
                ]
            ],
            columns: [
            [
                {
                    field: 'warehouseUnitId',
                    title: '库位 ',
                    width: 130,
                    align: 'center',
                },
                {
                    field: 'productName',
                    title: '物料名称 ',
                    width: 250,
                    align: 'left'
                },
                {
                    field: 'containerType',
                    title: '容器类型 ',
                    width: 75,
                    align: 'center',
                    formatter: function (value, row, index) {
                        if (value == 10) {
                            return "1Up";
                        } else if (value == 20) {
                            return "2Up";
                        } else if (value == 30) {
                            return "铜箔架";
                        }
                    }
                },
                {
                    field: 'isContainer',
                    title: '是否空容器 ',
                    width: 75,
                    align: 'center',
                    formatter: function (value, row, index) {
                        if (value == 1) {
                            return "<input type='checkbox' checked>";
                        } else {
                            return "<input type='checkbox'>";
                        }
                    }
                },
                {
                    field: 'coordinate',
                    title: '坐标',
                    width: 75,
                    align: 'center'
                },
                {
                    field: 'quantity',
                    title: '数量 ',
                    width: 150,
                    align: 'center'
                },
                {
                    field: 'remark',
                    title: '备注',
                    align: 'left',
                    width: 150
                },
            ]]
        });
    });

    var commonStockOut = {
        getJson: function (array) {
            if (array != undefined && array.length > 0) {
                var json = {};
                $(array).each(function (i, v) {
                    json[v.name] = v.value;
                });
                return json;
            } else {
                return {};
            }
        }
    }
</script>
